package cn.ococci.dm.Main.Core;

import android.os.SystemClock;

import cn.ococci.dm.Main.OtaType;
import cn.ococci.dm.Main.Tools.ThreadTool;



/**
 * Created by cyan on 16/1/22.
 * OTA 升级命令
 */
public class OtaVersionCommand implements CommandExecute {

    private SocketCommand doorCommand;
    private OtaType otaType = OtaType.NONE;
    private String localVersion;

    public OtaVersionCommand(SocketCommand doorCommand){
        this.doorCommand  = doorCommand;
    }

    public OtaVersionCommand(SocketCommand doorCommand,OtaType otaType,String localVersion){
        this.doorCommand = doorCommand;
        this.otaType = otaType;
        this.localVersion = localVersion;
    }


    @Override
    public void execute() {
        ThreadTool.runOnBgThread(new Runnable() {
            @Override
            public void run() {

                if(otaType == OtaType.NONE){

                    doorCommand.getOtaVersion(CommandType.COMMAND_OTA_VERSION);
                }else{

                    doorCommand.loopOtaVersion(CommandType.COMMAND_OTA_VERSION,otaType,localVersion);
                }

            }
        });
    }
}
